<template>
	<view class="order-content">
		<u-empty v-if="orderList.length==0 && !loadshow" margin-top="100" mode="order" iconSize="100" textSize="14"
			:text="$t('OrderEmpty')">
		</u-empty>
		<scroll-view scroll-y="true" style="height:100%;width:100%;">
			<view class="list" v-if="orderList.length!=0 && !loadshow" :style="{direction:i18nLocale=='ug'?'rtl':''}"
				v-for="(item,index) in orderList" @click="handdetail(item.id)">
				<!-- <view class="">{{item.order.out_trade_no}}</view> -->
				<view class="time">
					<text>{{$t('TimePlaced')}} : </text>
					<view class="" style="direction: ltr;">{{item.updated_at?item.updated_at:''}}</view>
				</view>
				<view class="time">
					<text>{{$t('OrderNumber')}} : </text>
					{{item.out_trade_no?item.out_trade_no:''}}
				</view>
				<view class="time">
					<text>{{$t('TableNumber')}} : </text>
					12
				</view>

				<view class="order-item">
					<view class="item" v-for="(subitem,sub_index) in item.items">
						<view class="left">
							<view class="name">{{i18nLocale=='ug'?subitem.ug_name:subitem.cn_name}}</view>
						</view>
						<view class="right">
							<view class="number">X{{subitem.qty}}</view>
							<view class="price">￥{{subitem.price}}</view>
						</view>
					</view>
					<view class="totalprice-box">
						<text>{{$t('TotalPrice')}}</text>
						<text class="totalprice">￥{{item.fee}}</text>
					</view>
				</view>
			</view>
		</scroll-view>
		<Loading :show="loadshow" iconName="circle" bgZindex="99" bgColor="" :text="$t('Loading')"></Loading>
	</view>
</template>

<script>
	import {
		getorders,
	} from '@/api/all.js';
	export default {
		components: {

		},
		props: {

		},
		data() {
			return {
				orderList: [],
				loadshow: true
			};
		},
		computed: {
			i18nLocale() {
				return this.$i18n.locale;
			},
		},
		mounted() {
			this.getOrderList()
		},
		methods: {
			getOrderList() {
				let that = this;
				that.loadshow = true;
				getorders({
					payment_status: 1
				}).then((res) => {
					if (res.code == 200) {
						console.log(res, '++++')
						let data = res.body.data;
						that.orderList = data;
						that.loadshow = false;
					}
				})
			}
		}

	}
</script>

<style lang="scss" scoped>
	.order-content {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		padding: 0rpx $uni-spacing-padding-sm;

		.list {
			width: 100%;
			// height:100%;
			height: clac;
			background: #FFFFFF;
			box-shadow: $uni-bg-shadow;
			border-radius: $uni-border-radius-lg;
			margin-top: 20rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			padding: 20rpx 40rpx;
			box-sizing: border-box;
			position: relative;

			.time {
				width: 100%;
				display: flex;
				align-items: center;
				justify-content: space-between;
				font-size: 28rpx;
				color: #000;
				padding: 14rpx 0rpx;

				text {
					color: #808080;
				}

				image {
					width: 80rpx;
					height: 80rpx;
				}
			}

			.order-item {
				width: 100%;
				display: flex;
				flex-direction: column;

				.item {
					width: 100%;
					display: flex;
					align-items: center;
					justify-content: space-between;
					padding: 20rpx 0rpx;

					.left {
						display: flex;
						align-items: center;

						.name {
							color: $uni-color-title;
							font-size: $uni-font-size-base;
							// padding: 0rpx 30rpx;
						}
					}

					.right {
						display: flex;
						align-items: center;

						.price {
							color: $uni-color-topic;
							font-size: $uni-font-size-base;
							padding: 0rpx 0rpx;
						}

						.number {
							color: $uni-text-color-grey;
							font-size: $uni-font-size-sm1;
							padding: 0rpx 30rpx;
						}

					}

				}

				.totalprice-box {
					display: flex;
					justify-content: space-between;
					// justify-content: center;
					align-items: center;
					font-size: 32rpx;
					padding: 10rpx 0rpx;

					.totalprice {
						color: #f4464b;
						font-size: 32rpx;
					}
				}

			}

		}
	}
</style>